function axios({
    method = "get",
    async = true,
    url
}) {
    return new Promise((resolve, reject) => {
        let xhr = new XMLHttpRequest()
        xhr.open(method, url, async);
        xhr.send();
        // onreadystatechange监听请求状态的变化 0 1 2 3 4 五个状态 4表示请求服务器数据成功
        xhr.onreadystatechange = function() {
            if (xhr.readyState === 4 && xhr.status === 200) {
                // console.log(xhr.responseText);
                let data = JSON.parse(xhr.responseText)
                    // console.log(data);
                resolve(data)
            }
        }
    })
}


axios.get = function(url) {
    return new Promise((resolve, reject) => {
        let xhr = new XMLHttpRequest()
        xhr.open('get', url, true);
        xhr.send();
        // onreadystatechange监听请求状态的变化 0 1 2 3 4 五个状态 4表示请求服务器数据成功
        xhr.onreadystatechange = function() {
            if (xhr.readyState === 4 && xhr.status === 200) {
                // console.log(xhr.responseText);
                let data = JSON.parse(xhr.responseText)
                    // console.log(data);
                resolve(data)
            }
        }
    })
}